<script>
    var tagId = utils.getQueryVariable('id');
    var column = utils.getQueryVariable('column');
    if(column!=null){
        $(".position span").html(" -> "+column);
    }

    $.ajax({
        url:ports.getTagListTdk,
        data: {
            plateIds: tagId
        },
        success:function (res) {
            console.log('获取标签列表tdk',res);
            $("title").text(res.data.channelTitle+'-政府采购信息网'||'政府采购信息网');
            $("meta[name='keywords']").prop('content',res.data.channelKeyword||'');
            $("meta[name='description']").prop('content',res.data.channelDescriptions||'');
        }
    })

    function getTagList(pageNum,resetPage){
        var pageSize = 12;
        $.ajax({
            url: ports.getArticleList,
            data: {
                plateIds: tagId,
                page:pageNum,
                size:pageSize
            },
            success:function(res) {
                console.log('获取标签列表',res);
                if(res.status==200){
                    var tagListHtml = '';
                    var tagList = res.data.list;
                    if(tagList&&tagList.length){
                        tagList.forEach(function (item) {
                            var keywordsListHtml = '';
                            item.articleKeywords.forEach(function (item1) {
                                keywordsListHtml += '<a href='+ item1.domain+'/web/tagList/1.html?tag='+item1.label+' target="_blank" class="tag">'+ item1.label +'</a>'
                            })
                            tagListHtml += '<li>\n' +
                                (item.articleImage ? '<div class="left">'+'<a target="_blank" href="' + (item.articleOutLinkStatus==0?item.articleUrl:item.articleOutLink) + '">' + '<img src=' + item.articleImage + ' alt=' + item.articleTitle + '></a></div>' : '')
                                +
                                '                    <div class="right">\n' +
                                '                        <h3 class="title"><a target="_blank" href="'+ (item.articleOutLinkStatus==0?item.articleUrl:item.articleOutLink) +'">'+ item.articleTitle +'</a></h3>\n' +
                                '                        <p></p>\n' +
                                '                        <div class="info">\n' +
                                '                            <i class="iconfont icon-shijian"></i><span>'+ item.articleReleaseTime.substr(0,10) +'</span>\n' +
                                '\n'
                                + keywordsListHtml +
                                '                        </div>\n' +
                                '                    </div>\n' +
                                '                </li>'
                        })
                    }else{
                        tagListHtml = '<li class="no-data">暂无数据</li>';
                        $('.list-pagination').remove();
                    }

                    $('ul.content-list').html(tagListHtml);
                    if(resetPage){
                        $('.list-pagination').pagination({
                            prevContent: '< 上一页',
                            nextContent: '下一页 >',
                            totalData: res.data.total||1,
                            showData: pageSize,
                            coping: true,
                            callback: function (api) {
                                console.log(api.getCurrent());
                                var current = api.getCurrent();
                                document.body.scrollTop = 0;
                                document.documentElement.scrollTop = 0;
                                getTagList(current,false);
                            }
                        });
                    }
                }
            }
        });
    }

    getTagList(1,true);

</script>
